<script setup lang="ts" name="PersonCard">
import Portrait from '@/components/Portrait/index.vue';
import { ref, watch } from 'vue';
import { Friend } from '@/types/index';

interface IProps {
  personInfo: Friend;
  pcCurrent: string;
}

const props = defineProps<IProps>();
const current = ref(props.pcCurrent);

watch(
  () => props.pcCurrent,
  val => {
    current.value = val;
  }
);
</script>

<template>
  <div class="person-card-page" :class="{ activeCard: props.personInfo.id === current }">
    <div class="person-info">
      <Portrait :img-url="personInfo.headImg"></Portrait>
      <div class="info-detail">
        <div class="name">{{ personInfo.name }}</div>
        <div class="detail">{{ personInfo.detail }}</div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.person-card-page {
  width: 250px;
  height: 80px;
  border-radius: 10px;
  background-color: rgb(50, 54, 68);
  position: relative;
  margin: 25px 0;
  cursor: pointer;

  .person-info {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 90%;
    transform: translate(-50%, -50%);
    overflow: hidden;
    display: flex;

    .info-detail {
      margin-left: 20px;
      .name {
        color: #fff;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        margin-bottom: 5px;
      }
      .detail {
        color: #5c6675;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: 12px;
      }
    }
  }
  &:hover {
    background-color: #1d90f5;
    transition: 0.4s;
    box-shadow: 0px 0px 10px 0px rgba(0, 136, 255);

    .detail {
      color: #fff !important;
    }
  }
}

.activeCard {
  background-color: #1d90f5;
  transition: 0.3s;
  box-shadow: 3px 2px 10px 0px rgba(0, 136, 255);

  .detail {
    color: #fff !important;
  }
}
</style>
